<template>
  <a class="ly-tab-item" :style="$parent.value === id ? activeStyle :color" @click="onItemClicked">
    <div class="ly-tab-item-icon" v-if="$parent.fixBottom">
      <slot name="icon"></slot>
    </div>
    <div class="ly-tab-item-label">
      <slot></slot>
    </div>
  </a>
</template>

<script>
export default {
  name: "LyTabItem",
  computed: {
    activeStyle() {
      return {
        color: this.$parent.activeColor
        // fontSize: '16px'
      };
    },

    color() {
      return {
        color: this.$parent.color
        // fontSize: '16px'
      };
    }
  },
  data() {
    return {
      id: ( this.$parent.$children.length || 1) - 1,
    };
  },
    // watch: {
    //     id(newValue,oldValue){
    //         console.log(newValue)
    //         console.log(oldValue)
    //         if(newValue!=oldValue){
    //             console.log('ididw');
    //         }
    //     }
    // },
  methods: {
    onItemClicked() {
      this.$parent.$emit("input", this.id);
    }
  },
  mounted(){
      console.log(this.id)
    }
};
</script>

<style>
.ly-tab-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-decoration: none;
  text-align: center;
  margin-right:10px;
}
a {
  color: #000;
}

.ly-tab-item-icon {
  margin: 0 auto 5px;
}
</style>
